#include <Windows.h>
#include <stdio.h>

#include "pedumperlearn.h"
#include "debugmode.h"

// QQQ, later from command line
#define FILE_NAME L"t.dll"
//#define FILE_NAME L"kernel32.dll"

DWORD wmain(DWORD argc, WCHAR * argv[])
{
    EXECUTABLEFILE peFile;

    if (OpenAndMapExecutableFile(FILE_NAME, &peFile))
    {
        printf("[ERROR] OpenAndMapExecutable failed with 0x%08x, on %S\n", GetLastError(), FILE_NAME);
        EnsureToCloseDebugeLogFile();
        return -1;
    }

    //PrintRawHeaders(&peFile);

    PrintExportsRaw(&peFile);

    PrintImportsRaw(&peFile);

    if (UnMapAndCloseExecutableFile(&peFile))
    {
        printf("[ERROR] UnMapAndCloseExecutableFile failed with 0x%08x, on %S\n", GetLastError(), FILE_NAME);
        EnsureToCloseDebugeLogFile();
        return -1;
    }

	EnsureToCloseDebugeLogFile();
    
    return 0;
}